package com.leyou.feign;
import com.leyou.common.constants.LyConstants;
import com.leyou.scheduler.AppTokenScheduler;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *feign 拦截器
 */
@Component
public class FeignInterceptor implements RequestInterceptor {
    @Autowired
    private AppTokenScheduler appTokenScheduler;
    @Override
    public void apply(RequestTemplate template) {
        System.out.println("token ========:"+appTokenScheduler.getAppToken());
        template.header(LyConstants.APP_TOKEN_HEADER,appTokenScheduler.getAppToken());

    }
}
